package com.ssm.service.impl;

import com.ssm.mapper.AdminMapper;
import com.ssm.pojo.Admin;
import com.ssm.pojo.vo.AdminVO;
import com.ssm.pojo.vo.Result;
import com.ssm.service.IAdminService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl implements IAdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Override
    public Result<AdminVO> login(String adminName, String password) {
        Admin admin = this.adminMapper.login(adminName, password);
        if (admin == null){
            return Result.error(5000,"用户名或密码错误");
        }
        AdminVO adminVO = new AdminVO();
        // 将admin对象中的属性复制给adminVO对象
        BeanUtils.copyProperties(admin,adminVO);
        return Result.success(2000,adminVO);
    }
}
